package org.dentalcard.xml;

import junit.framework.TestCase;
import org.dentalcard.service.impl.MenuManager;
import org.dentalcard.ui.calendar.DayCalendarScr;
import org.dentalcard.ui.security.UserManagementScr;
import org.junit.Ignore;
import org.junit.Test;

import javax.xml.bind.JAXBContext;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.util.ArrayList;

/**
 * @user: Vladimir Chernishov
 * @date: 20.12.11
 * @time: 23:33
 */
public class MenuCreator {

    @Ignore
    @Test
    public void createMenu()throws Exception{

        JAXBContext jc = JAXBContext.newInstance(XMLMenu.class, XMLMenuItem.class);
        XMLMenu menu = new XMLMenu();
        menu.setName("Menu");
        menu.setMenu(new ArrayList<XMLMenu>());
        XMLMenu security = new XMLMenu();
        security.setName("Security");
        menu.getMenu().add(security);
        menu.setItems(new ArrayList<XMLMenuItem>());
        XMLMenuItem item = new XMLMenuItem();
        item.setName("One Day Calendar");
        item.setClaz(DayCalendarScr.class);

        menu.getItems().add(item);

        XMLMenuItem userManagement = new XMLMenuItem();
        userManagement.setName("User MAnagement");
        userManagement.setClaz(UserManagementScr.class);

        security.setItems(new ArrayList<XMLMenuItem>());
        security.getItems().add(userManagement);

        jc.createMarshaller().marshal(menu, new FileOutputStream("src/main/java/menu.xml"));

    }

    @Test
    public void testGetMenu(){
        MenuManager menuManager = new MenuManager();
        XMLMenu menu = menuManager.getMenu();

        TestCase.assertNotNull(menu);
    }

}
